<template>
	<el-container>
		<el-header class='x-header'>
			<b class="title">{{ page_info.title }}</b>
			<el-button v-if="$route.query.callback_url" size="mini" icon="el-icon-back" @click="g_page.funcBack">
				返回
			</el-button>
			<el-button size="mini" type="success" icon="el-icon-edit" @click="g_page.funcRedirectEdit(`app_car__network__edit`)">
				添加
			</el-button>
			<el-button size="mini" type="danger" icon="el-icon-delete" @click="g_page.funcDel()">删除</el-button>
			<el-button size="mini" icon="el-icon-refresh" @click="g_page.funcReload()">刷新</el-button>
		</el-header>
		<el-main class='x-main'>
			<el-form :inline="true" :model="form_q" size="mini">
				<el-form-item label="名称">
					<el-input name="compKw" v-model="form_q.compKw" placeholder="名称"></el-input>
				</el-form-item>
				<el-form-item label="省">
					<el-input name="compKw" v-model="form_q.compProvince" placeholder="省"></el-input>
				</el-form-item>
				<el-form-item label="市">
					<el-input name="compKw" v-model="form_q.compCity" placeholder="市"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="g_page.funcSearch">搜索</el-button>
				</el-form-item>
			</el-form>
			<div class="table-wrap">
				<el-table stripe ref="multipleTable" tooltip-effect="dark"
						  @selection-change="g_page.funcTableSelectionChange"
						  :data="list_data">
					<el-table-column type="selection"></el-table-column>
					<el-table-column label="ID">
						<template slot-scope="data">
							<div v-html="data.row.id"></div>
						</template>
					</el-table-column>
					<el-table-column label="名称">
						<template slot-scope="data">
							<div v-html="data.row.cnetwork_name"></div>
						</template>
					</el-table-column>
					<el-table-column label="标签">
						<template slot-scope="data">
							<div v-html="data.row.cnetwork_tag"></div>
						</template>
					</el-table-column>
					<el-table-column label="地址">
						<template slot-scope="data">
							{{ data.row.cnetwork_province }} {{ data.row.cnetwork_city }}
							{{ data.row.cnetwork_district}} {{ data.row.cnetwork_address }}
						</template>
					</el-table-column>
					<el-table-column label="坐标">
						<template slot-scope="data">
							<Location type="1" :lng="data.row.cnetwork_lng" :lat="data.row.cnetwork_lat" :x="data.row.cnetwork_x_id"></Location>
						</template>
					</el-table-column>
					<el-table-column label="车位余量/总量">
						<template slot-scope="data">
							<b style="color:blue;">{{ data.row.left_count }}</b> / {{ data.row.cnetwork_car_total }}
						</template>
					</el-table-column>
					<el-table-column label="状态">
						<template slot-scope="data">
							<div style="color:red;" v-if="data.row.cnetwork_hide==1">隐藏</div>
							<div v-else>显示</div>
						</template>
					</el-table-column>
					<el-table-column fixed="right" label="操作">
						<template slot-scope="data">
							<el-button type="text" size="mini" @click="g_page.funcRedirectEdit('app_car__network__edit',data.row)">
								编辑
							</el-button>
							<el-button type="text" size="mini" @click="g_page.funcRedirectEdit(`app_car__network__sku__add?pid=${data.row.id}`)">
								车辆分配
							</el-button>
							<el-button type="text" size="mini" @click="g_page.funcRedirectEdit(`app_car__sku__list?network_id=${data.row.id}`)">
								车辆列表
							</el-button>
						</template>
					</el-table-column>
				</el-table>
				<a target="_blank"></a>
			</div>
		</el-main>
		<!---->
		<!---->
		<!-- 分页 -->
		<el-footer v-if="page_show" class="x-page">
			<el-pagination class="paging" background layout="total, sizes, prev, pager, next, jumper"
						   @current-change="g_page.funcPageChange" :page-sizes="[page_size]"
						   :current-page="page_index" :page-size="page_size" :total="page_total">
			</el-pagination>
		</el-footer>
		<!---->
		<!---->
		<!-- 弹框 -->
		<el-dialog :title="form.app_idx+'配置'" :visible.sync="form_dialog_visible" width="70%">
			<el-form ref="form" :rules="form_rules" :model="form" size="mini" label-width="15%">
				<el-form-item label="入口链接" v-if="!g_page.funcIsAdminAdd()">
					<el-input :disabled="true" v-model="form.oauth_url"/>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="g_page.funcBack" size="mini">取消</el-button>
				<el-button type="success" @click="g_page.funcSave" size="mini">保存</el-button>
			</div>
		</el-dialog>
		<!---->
		<!---->
		<!---->
	</el-container>
</template>


<script>
	import Location from '@/views/app_wxapp/app_car/components/Location'

	export default {
		components: {
			Location
		},
		data() {
			let page_data = { super_uid: '' }
			//
			page_data = this.g_cc.funcGetInitData(page_data)
			//
			return page_data
		},
		mounted() {
			console.log('mounted')
			//
			this.g_page.funcSetVue(this)
			// 应用ID
			this.g_page.funcSetApiUrlList('/xadmin/app_car/app_car__network__list')
			this.g_page.funcSetApiUrlDel('/xadmin/app_car/app_car__network__list/del')
			//页码
			this.g_page.funcSetPageSize(20)
			//搜索
			this.form_q = {
				'compKw': ''
			}
			this.g_page.funcGetList()
			//
			this.form_rules = {
				acc_uidX: [
					{
						required: true,
						message: '必填',
						trigger: 'blur'
					}
				]
			}
			//
		},
		methods: {
			////////////////////
		}
	}
</script>

